<?php 



$menuitems = array();


//array(url,display,active)

$menuitems["emp_view.php"]				="EMPLOYEES";
$menuitems["client_view.php"]			="CLIENTS";
$menuitems["svc_view.php"]				="SERVICES";
$menuitems["billing_view.php?bill"]		="BILLING SLIPS";
$menuitems["billing_view.php?time"]		="TIME SLIPS";
$menuitems["billing_view.php"]			="BILLING";

dumpit($menuitems);

function dumpit($obj){
	echo "\n\n\n<!-- \n";
	echo "********************************************";
	print_r($obj);
	echo "********************************************";
	echo "\n -->\n\n";
}

function buildMenuItems($items=array(),$phpself=""){
	$phpself=(!empty($phpself))?$phpself:$_SERVER['PHP_SELF'];
	$phpself=explode("?",$phpself);
	$page=trim($phpself[0],"/");
	$qs=(isset($phpself[1]) && !empty($phpself[1])) ? $phpself[1] : $_SERVER['QUERY_STRING'] ;
	
	
	dumpit($phpself);
	dumpit($page);
	dumpit($qs);
	
	$return="";
	
	foreach($items as $href => $display){
		
		$parts				= explode("?",$href);
		$qs_match			= (isset($parts[1]) && $qs!=$parts[1])? false : true;
		$qs_match			= (!empty($qs) && (!isset($parts[1]) || empty($parts[1])))? false : $qs_match;
		$page_match 		= (isset($parts[0]) && $page==$parts[0])? true : false;
		$is_active 			= ($qs_match && $page_match)? true : false;
		$title 				= ($is_active) ? "[ ".$display." ]" : "&nbsp;".$display."&nbsp;" ;
		$css 				= ($is_active) ? "color:yellow;font-weight:bold;" : "" ;

		
		
		$return .= "<li><a href=\"".$href."\" style=\"".$css."\">".$title."</a></li>\n";
	}
	
	return $return;
}

$menu_html = buildMenuItems($menuitems);
?>
<div id="menu">
	<ul>
		<li class="first"><a href="index.php"><img src="images/nav_home.png" width="20" height="15" alt="GO BACK HOME" border="0" style="margin:0px;" align="absmiddle" /></a></li>
<!-- 
		<li><a href="emp_view.php">EMPLOYEES</a></li>
		<li><a href="client_view.php">CLIENTS</a></li>
		<li><a href="svc_view.php">SERVICES</a></li>
		<li><a href="billing_view.php?bill">BILLING SLIPS</a></li>
		<li><a href="billing_view.php?time">TIME SLIPS</a></li>
		<li><a href="billing_view.php">BILLING</a></li>
-->

<?php echo $menu_html; ?>



	</ul>
</div>
